AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

local function Knockback(ent, inflictor, attacker, damage, dmginfo)
	if ent && attacker && attacker:GetNWBool("Knockbackd") then
		if dmginfo:IsBulletDamage() || dmginfo:IsExplosionDamage() then
			local dmgpos = dmginfo:GetDamagePosition()
			dmgpos:Sub(ent:GetPos())
			local damagevec = dmgpos:GetNormal()
			damagevec:Mul(damage*-100)
			damagevec:Add(Vector(0, 0, 600))
			ent:SetVelocity(damagevec)
			local phys = ent:GetPhysicsObject()
			if phys then
				phys:SetVelocity(damagevec)
			end
			PrintMessage(1, tostring(damagevec))
			if ent:IsPlayer() then
				StunPlayer(ent, damage*.25)
			end
		end
	end
end
hook.Add("EntityTakeDamage", "Knockback", Knockback)